<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 汪利东,2016-04-19 13:32
// +----------------------------------------------------------------------

namespace Delivery\Controller;


class UserController extends BaseController
{
    //修改登录密码
    public function handleChange()
    {
        $map['man_id'] = session('delivery_man.man_id');
        $map['passowrd'] = sha1(I('post.old_password'));
        $r = M('delivery_man')->where($map)->find();
        if (empty($r)) {
            die(json_encode(['code' => 0, 'msg' => '原密码错误']));
        }
        $r = M('delivery_man')->where($map)->setField('password', sha1(I('post.new_password')));
        if (empty($r)) {
            die(json_encode(['code' => 0, 'msg' => '未知错误']));
        } else {
            session('delivery_man', null);
            die(json_encode(['code' => 1]));
        }
    }
}